home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 03020103.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  4.8 KB  |  70 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Open Statement[Runtime]</title><meta name="filename" content="text/sbasic/common/03020103"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle1{
  5.                 }
  6.         span.Tabelle1A{
  7.                 width:1.499cm;}
  8.         span.Tabelle1B{
  9.                 width:16.498cm;}
  10.         tr.Tabelle11{
  11.                 }
  12.         td.Tabelle1A1{
  13.                 }
  14.         p.P1{
  15.                 }
  16.         p.P2{
  17.                 }
  18.         span.T1{
  19.                 font-weight:bold;}
  20.         span.fr1{
  21.                 }
  22.         </style></head><body>
  23.   
  24.   
  25.   <help:to-be-embedded Eid="open" xmlns:help="http://openoffice.org/2000/help"><a name="open"/>
  26.   <p class="Head1"><help:link Id="66386">Open Statement[Runtime]</help:link></p>
  27.   <p class="Paragraph">Opens a data channel.</p>
  28.   </help:to-be-embedded>
  29.   <p class="Paragraph"><span class="T1">Syntax</span>:</p>
  30.   <p class="Paragraph">Open FileName As String [For Modus] [Access IOMode] [protected] As [#]FileName As Integer [Len = Datasetlength] <help:key-word value="Open" tag="kw66386_1" xmlns:help="http://openoffice.org/2000/help"/></p>
  31.   <p class="Paragraph"><span class="T1">Parameter</span>:</p>
  32.   <p class="Paragraph">FileName: Name and path of the file to be opened. If the file does not exist when you open it for reading (Access = Read), an error message appears. If you open a non-existing file for writing (Access = Write), a new file will be created.</p>
  33.   <p class="Paragraph">Mode: Keyword that specifies the file mode. Valid values: Append (append to sequential file), binary (data can be accessed by bytes using Get and Put), Input (opens data channel for reading), Output (opens data channel for writing), and Random (edits relative files).</p>
  34.   <p class="Paragraph">Access: Keyword that defines the access type. Valid values: Read (read-only), Write (write-only), Read Write (both).</p>
  35.   <p class="Paragraph">Protected: Keyword that defines the security status of a file after opening. Valid values: Shared (file may be opened by other applications), Lock Read (file is protected against reading), Lock Write (file is protected against writing), Lock Read Write (denies file access).</p>
  36.   <p class="Paragraph">FileNumber: Any integer expression ranging from 0-511 indicating the number of a free data channel, which can later be used to access the file with various commands. The file number should be determined immediately before the Open statement using the FreeFile function.</p>
  37.   <p class="Paragraph">DatasetLength: <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>For relative files, returns the length of a certain record. This parameter is only necessary if the file was opened for Random access.</p>
  38.   <table><tr class="Tabelle11"><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  39.       <p class="TextInTable"><draw:image draw:style-name="fr1" draw:name="HIND_1" text:anchor-type="paragraph" svg:width="0.847cm" svg:height="0.847cm" draw:z-index="0" xlink:href="65980" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:filter-name="GIF - Graphics Interchange" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:text="http://openoffice.org/2000/text" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  40.      </span></th><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1B">
  41.       <p class="TextInTable">A file must be opened with the Open statement before the file contents can be modified. If you try to open a file that is already opened, an error message occurs.</p>
  42.      </span></th></tr></table>
  43.   <p class="Paragraph"/>
  44.   <p class="P2">Example:</p>
  45.   <p class="PropText">Sub ExampleWorkWithAFile</p>
  46.   <p class="PropText">Dim iNumber As Integer</p>
  47.   <p class="PropText">Dim sLine As String</p>
  48.   <p class="PropText">Dim aFile As String</p>
  49.   <p class="PropText">Dim sMsg as String</p>
  50.   <p class="PropText">aFile = "c:\data.txt"</p>
  51.   <p class="PropText"/>
  52.   <p class="PropText">iNumber = Freefile</p>
  53.   <p class="PropText">Open aFile For Output As #iNumber</p>
  54.   <p class="PropText">Print #iNumber, "This is a line of text"</p>
  55.   <p class="PropText">Print #iNumber, "This is another line of text"</p>
  56.   <p class="PropText">Close #iNumber</p>
  57.   <p class="PropText"/>
  58.   <p class="PropText">iNumber = Freefile</p>
  59.   <p class="PropText">Open aFile For Input As iNumber</p>
  60.   <p class="PropText">While not eof(iNumber)</p>
  61.   <p class="PropText">Line Input #iNumber, sLine</p>
  62.   <p class="PropText">If sLine <>"" then</p>
  63.   <p class="PropText">sMsg = sMsg & sZeile & chr(13)</p>
  64.   <p class="PropText">end if</p>
  65.   <p class="PropText">wend</p>
  66.   <p class="PropText">Close #iNumber</p>
  67.   <p class="PropText">Msgbox sMsg</p>
  68.   <p class="PropText">End Sub</p>
  69.   <p class="PropText"/>
  70.  </body></html>